/*
 * @describe 日志 Service
 * @author yisin
 * @date 2014-12-21 00:44:30
 */
package com.yisin.pbox.www.logs.service;

import org.springframework.stereotype.Service;

import com.yisin.pbox.bean.pojo.system.Logs;
import com.yisin.pbox.frame.common.Response;
import com.yisin.pbox.frame.common.SpringContainer;
import com.yisin.pbox.frame.common.StatusCode;
import com.yisin.pbox.frame.log.ILogger;
import com.yisin.pbox.frame.log.LogFactory;
import com.yisin.pbox.www.logs.ILogsDao;
import com.yisin.pbox.www.logs.ILogsService;

/**
 * <pre>
 * 日志 Service
 * </pre>
 * 
 * @author yisin
 * @date 2014-12-21 00:44:30
 * 
 */
@Service("logsService")
public class LogsService implements ILogsService {
	private static ILogger logger = LogFactory
			.getDefaultLogger(LogsService.class);

	/**
	 * <pre>
	 * 根据ID获取日志数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response getDataById(int logId) {
		logger.debug("In getDataById");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.getDataById(logId);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 模糊搜索日志数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response loadAndSearch(Logs logs) {
		logger.debug("In loadAndSearch");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.loadAndSearch(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 高级搜索日志数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response advancedSearch(Logs logs) {
		logger.debug("In advancedSearch");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.advancedSearch(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}
	
	/**
	 * <pre>
	 * 精确查询日志数据
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response selectDataForAccurate(Logs logs) {
		logger.debug("In selectDataForAccurate");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.selectDataForAccurate(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 新增日志记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response insertData(Logs logs) {
		logger.debug("In insertData");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.insertData(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 修改日志记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response updateData(Logs logs) {
		logger.debug("In updateData");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.updateData(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

	/**
	 * <pre>
	 * 删除日志记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response deleteData(Logs logs) {
		logger.debug("In deleteData");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.deleteData(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}
	
	/**
	 * <pre>
	 * 审核日志记录
	 * </pre>
	 * 
	 * @author yisin
	 * @date 2014-12-21 00:44:30
	 */
	public Response auditingData(Logs logs) {
		logger.debug("In auditingData");
		Response res = new Response();
		try {
			ILogsDao rdao = (ILogsDao) SpringContainer.getBeanByName("logsDao");
			res = rdao.auditingData(logs);
		} catch (Exception e) {
			res.setStatusCode(StatusCode.DBSQL_ERROR);
			logger.error("Record the Operating log failed, Cause: ", e);
		}
		return res;
	}

}
